/**
 * <p>Title: InitIndexAction.java</p>
 * <p>Description: DoNotes</p>
 * @author WangJun
 * @date 2009/11/15 20:58:05
 * @version 1.0
 */
package net.donotes.blog.action;

import java.util.List;

import net.donotes.blog.pojo.Post;
import net.donotes.blog.service.PostService;
import net.donotes.util.NaviPage;

/**
 * @author WangJun
 *
 */
public class InitIndexAction extends BaseAction {

	private static final long serialVersionUID = 1L;
	
	private List<Post> posts = null;
	private NaviPage naviPage = null;
	private int startPageNum = 1;
	private int endPageNum = 1;
	private int page = 1;
	private String category = null;

	/**
	 * @return the posts
	 */
	public List<Post> getPosts() {
		return posts;
	}

	public String execute() {
		PostService postServiec = new PostService();
		this.posts = postServiec.listPost(this.page, this.category);
		this.naviPage = new NaviPage(this.category);
		return SUCCESS;
	}

	/**
	 * @return the startPageNum
	 */
	public int getStartPageNum() {
		return this.naviPage.getStartPageNum(this.page);
	}

	/**
	 * @return the endPageNum
	 */
	public int getEndPageNum() {
		return this.naviPage.getEndPageNum(this.page);
	}

	/**
	 * @return the page
	 */
	public int getPage() {
		return page;
	}

	/**
	 * @param page the page to set
	 */
	public void setPage(int page) {
		this.page = page;
	}

	/**
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 * @param category the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}
}